<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>绝对定位</title>
    <style>
        /* 绝对定位默认是以网页左上角为定位的,但是给父元素设置相对定位后,子元素就能够以父元素为参考点 */
        div.p {
            width: 700px;
            height: 500px;
            border: 1px solid #000000;
            margin: 0 auto;
            position: relative;
        }

        div.c {
            width: 20px;
            padding: 20px;
            background-color: green;
            position: absolute;
            left: 20px;
            top: 20px;
        }
    </style>
</head>

<body>
    <div class="p">
        <div class="c"></div>
    </div>
</body>

</html>